<template>
<div class="rights-box">
<!--面包屑-->
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>权限管理</el-breadcrumb-item>
    <el-breadcrumb-item>权限列表</el-breadcrumb-item>
  </el-breadcrumb>
<!--权限列表-->
  <el-row>
    <el-card>
      <el-table
        :data="rightsData"
        border
        style="width: 100%">
        <el-table-column
          label="#"
          type="index"
          width="50">
        </el-table-column>
        <el-table-column
          prop="authName"
          label="权限名称"
          width="180">
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径"
          width="180">
        </el-table-column>
        <el-table-column
          label="权限等级">
          <template v-slot="scope">
            <el-tag v-if="scope.row.level == 0">一级权限</el-tag>
            <el-tag  type="success"  v-if="scope.row.level == 1">二级权限</el-tag>
            <el-tag  type="warning"  v-if="scope.row.level == 2">三级权限</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </el-row>
</div>
</template>

<script>
export default {
  name: 'rights',
  data() {
    return {
      rightsData: [
      ],
      type: 'list'
    }
  },
  created() {
    this.getRights()
  },
  methods:{
    async getRights(){
    const {data: res} =  await this.$http.get(`rights/${this.type}`)
      if(res.meta.status !== 200) return this.$message.error('获取权限列表失败！')
      this.rightsData = res.data
      this.$message.success(res.meta.msg)
    }
  }
}
</script>

<style lang="scss" scoped>
.el-breadcrumb {
  margin-bottom: 15px;
}

.el-card {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15) !important;
}

.el-table {
  margin: 15px 0;
}
</style>
